package top.lishuoboy.spring.bean;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

@Slf4j
//@Component // 注释掉，不然每个bean加载都打日志，太乱
public class MyBeanPostProcessor implements BeanPostProcessor {
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        log.info("{} 初始化之前执行, 后置处理器BeanPostProcessor, bean=={}", beanName, bean);
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        log.info("{} 初始化之后执行, 后置处理器BeanPostProcessor, bean=={}", beanName, bean);
        return bean;
    }
}